package input;

import java.io.File;
import java.util.Vector;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

public class ExcelTools {

	public static Vector<String[]> importXLS(File f, int sheetNo) {
		Vector<String[]> data = new Vector<String[]>();
		if (f != null) {
			Workbook workbook = null;
			try {
				workbook = Workbook.getWorkbook(f);
				Sheet sheet = workbook.getSheet(sheetNo);
				int anz = sheet.getRows();
				for (int i = 0; i < anz; i++) {
					try {
						Cell[] cells = sheet.getRow(i);
						String[] s = new String[cells.length];
						for (int j = 0; j < cells.length; j++) {
							try {
								s[j] = cells[j].getContents().replace(",", ".");
							} catch (Exception ex) {
								s[j] = "";
							}
						}
						data.add(s);
					} catch (Exception ex) {
					}
				}
				workbook.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return data;
	}
}
